package com.yyg.boot.web;

import com.yyg.boot.entity.Person;
import com.yyg.boot.repository.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description Description
 * @Author 一一哥Sun
 * @Date Created in 2020/3/28
 */
@RestController
public class HelloController {

    @Autowired
    private PersonRepository repository;

    @RequestMapping("/all")
    public HttpEntity<Person> greeting(@RequestParam(value = "name", defaultValue = "yiyige") String name) {
        Person person = repository.findAll().iterator().next();
        return new ResponseEntity<>(person, HttpStatus.OK);
    }

}
